package cn.kbyue.eurekaserver.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceCanceledEvent;
import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceRegisteredEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

/**
 * listener
 *
 * @author xl
 * @date 2020/8/18 20:45
 */
@Component
public class ListenerConfig {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @EventListener
    public void cancel(EurekaInstanceCanceledEvent canceledEvent) {
        logger.info(">> {} App服务下线!", canceledEvent.getAppName());
    }

    @EventListener
    public void up(EurekaInstanceRegisteredEvent registeredEvent) {
        logger.info(">> {} App服务注册!", registeredEvent.getInstanceInfo().getAppName());
    }

}
